<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>流程控制以及数组</title>
</head>
<body>

</body>
<script>
    //if语句与java类似
    let month = 10;
    if (month >= 3 && month <= 5) {
        document.write("春季");
    }else if(month >= 6 && month <= 8) {
        document.write("夏季");
    }else if(month >= 9 && month <= 11) {
        document.write("秋季");
    }else if(month == 12 || month == 1 || month == 2) {
        document.write("冬季");
    }else {
        document.write("月份有误");
    }

    document.write("<br>");

    switch (month) {
        case 3:
        case 4:
        case 5:
        case 6:
            document.write("春季");
            break;
        case 6:
        case 7:
        case 8:
            document.write("夏季");
            break;
        case 9:
        case 10:
        case 11:
            document.write("秋季");
            break;
        case 12:
        case 1:
        case 2:
            document.write("冬季");
            break;
        default:
            document.write("月份有误");
            break;
    }

    document.write("<br>");

    //数组定义,索引从0开始
    let arr = [0, 1, 2, 3, 4, 5];
    //数组长度无限制，没有定义的话输出为undefined
    arr[7] = 7;

    //使用for循环输出
    for(let i=0;i< arr.length;i++){
        document.write(arr[i]+"<br>");
    }
    //使用while输出
    let i = 0;
    while (i < arr.length) {
        document.write(arr[i]+"<br>");
        i++
    }
    let j = 0;
    //使用do｛｝while()循环输出
    do{
        document.write(arr[j]+"<br>");
        j++;
    }while (j < arr.length);

</script>
</html>